﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    public class SysParam
    {
        private readonly DAL.SysParam dal = new DAL.SysParam();
        public SysParam()
        { }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.SysParam> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 保存系统参数
        /// <cretor>wangl</cretor>
        /// <date>2012-12-06</date>
        /// </summary>
        /// <param name="sysList"></param>
        public void SaveSysparam(List<Model.SysParam> sysList)
        {
            dal.SaveSysparam(sysList);
        }

        /// <summary>
        /// 获取参数值
        /// <cretor>wangl</cretor>
        /// <date>2013-08-05</date>
        /// </summary>
        /// <param name="paramNo">参数编号</param>
        /// <param name="entityNo">公司编号</param>
        /// <returns></returns>
        public string GetParamValue(string paramNo, string entityNo)
        {
            return dal.GetParamValue(paramNo, entityNo);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.SysParam> DataTableToList(DataTable dt)
        {
            List<Model.SysParam> modelList = new List<Model.SysParam>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.SysParam model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.SysParam();
                    if (dt.Rows[n]["FFParamNo"] != null && dt.Rows[n]["FFParamNo"].ToString() != "")
                    {
                        model.FFParamNo = dt.Rows[n]["FFParamNo"].ToString();
                    }
                    if (dt.Rows[n]["FEntityNo"] != null && dt.Rows[n]["FEntityNo"].ToString() != "")
                    {
                        model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    }
                    if (dt.Rows[n]["FFParamName"] != null && dt.Rows[n]["FFParamName"].ToString() != "")
                    {
                        model.FFParamName = dt.Rows[n]["FFParamName"].ToString();
                    }
                    if (dt.Rows[n]["FFValue"] != null && dt.Rows[n]["FFValue"].ToString() != "")
                    {
                        model.FFValue = dt.Rows[n]["FFValue"].ToString();
                    }
                    if (dt.Rows[n]["FFNote"] != null && dt.Rows[n]["FFNote"].ToString() != "")
                    {
                        model.FFNote = dt.Rows[n]["FFNote"].ToString();
                    }
                    if (dt.Rows[n]["FFconfirm"] != null && dt.Rows[n]["FFconfirm"].ToString() != "")
                    {
                        model.FFconfirm = dt.Rows[n]["FFconfirm"].ToString();
                    }
                    if (dt.Rows[n]["FFCanModify"] != null && dt.Rows[n]["FFCanModify"].ToString() != "")
                    {
                        model.FFCanModify = dt.Rows[n]["FFCanModify"].ToString();
                    }
                    if (dt.Rows[n]["FFContent"] != null && dt.Rows[n]["FFContent"].ToString() != "")
                    {
                        model.FFContent = dt.Rows[n]["FFContent"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }
    }
}
